using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Xml;
using System.Xml.Linq;
using ns17;
using ns20;

namespace Newtonsoft.Json.Converters
{
	public class XmlNodeConverter : JsonConverter
	{
		[CompilerGenerated]
		private sealed class Class106
		{
			public Interface10 interface10_0;

			public bool method_0(Interface10 interface10_1)
			{
				return interface10_1.String_0 == interface10_0.String_0;
			}
		}

		[CompilerGenerated]
		private sealed class Class107
		{
			public string string_0;

			public bool method_0(Interface12 interface12_0)
			{
				return interface12_0.String_0 == string_0;
			}
		}

		[CompilerGenerated]
		private sealed class Class108
		{
			public string string_0;

			public bool method_0(Interface12 interface12_0)
			{
				return interface12_0.String_0 == string_0;
			}
		}

		private const string string_0 = "#text";

		private const string string_1 = "#comment";

		private const string string_2 = "#cdata-section";

		private const string string_3 = "#whitespace";

		private const string string_4 = "#significant-whitespace";

		private const string string_5 = "?xml";

		private const string string_6 = "http://james.newtonking.com/projects/json";

		[CompilerGenerated]
		private string string_7;

		[CompilerGenerated]
		private bool bool_0;

		[CompilerGenerated]
		private bool bool_1;

		[CompilerGenerated]
		private static Func<Interface10, bool> func_0;

		[CompilerGenerated]
		private static Func<Interface10, bool> func_1;

		public string DeserializeRootElementName
		{
			[CompilerGenerated]
			get
			{
				return string_7;
			}
			[CompilerGenerated]
			set
			{
				string_7 = value;
			}
		}

		public bool WriteArrayAttribute
		{
			[CompilerGenerated]
			get
			{
				return bool_0;
			}
			[CompilerGenerated]
			set
			{
				bool_0 = value;
			}
		}

		public bool OmitRootObject
		{
			[CompilerGenerated]
			get
			{
				return bool_1;
			}
			[CompilerGenerated]
			set
			{
				bool_1 = value;
			}
		}

		public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
		{
			Interface10 interface10_ = method_0(value);
			XmlNamespaceManager xmlNamespaceManager_ = new XmlNamespaceManager(new NameTable());
			method_1(interface10_, xmlNamespaceManager_);
			if (!OmitRootObject)
			{
				writer.WriteStartObject();
			}
			method_6(writer, interface10_, xmlNamespaceManager_, !OmitRootObject);
			if (!OmitRootObject)
			{
				writer.WriteEndObject();
			}
		}

		private Interface10 method_0(object object_0)
		{
			if (object_0 is XObject)
			{
				return Class99.smethod_0((XObject)object_0);
			}
			if (!(object_0 is XmlNode))
			{
				throw new ArgumentException("Value must be an XML object.", "value");
			}
			return new Class93((XmlNode)object_0);
		}

		private void method_1(Interface10 interface10_0, XmlNamespaceManager xmlNamespaceManager_0)
		{
			List<Interface10> list = null;
			Interface10 @interface = interface10_0;
			while ((@interface = @interface.Interface10_0) != null)
			{
				if (@interface.XmlNodeType_0 == XmlNodeType.Element)
				{
					if (list == null)
					{
						list = new List<Interface10>();
					}
					list.Add(@interface);
				}
			}
			if (list == null)
			{
				return;
			}
			list.Reverse();
			foreach (Interface10 item in list)
			{
				xmlNamespaceManager_0.PushScope();
				foreach (Interface10 item2 in item.Prop_1)
				{
					if (item2.String_2 == "http://www.w3.org/2000/xmlns/" && item2.String_0 != "xmlns")
					{
						xmlNamespaceManager_0.AddNamespace(item2.String_0, item2.String_1);
					}
				}
			}
		}

		private string method_2(Interface10 interface10_0, XmlNamespaceManager xmlNamespaceManager_0)
		{
			string text = ((interface10_0.String_2 == null || (interface10_0.String_0 == "xmlns" && interface10_0.String_2 == "http://www.w3.org/2000/xmlns/")) ? null : xmlNamespaceManager_0.LookupPrefix(interface10_0.String_2));
			if (!string.IsNullOrEmpty(text))
			{
				return text + ":" + interface10_0.String_0;
			}
			return interface10_0.String_0;
		}

		private string method_3(Interface10 interface10_0, XmlNamespaceManager xmlNamespaceManager_0)
		{
			switch (interface10_0.XmlNodeType_0)
			{
			case XmlNodeType.Element:
				return method_2(interface10_0, xmlNamespaceManager_0);
			case XmlNodeType.Attribute:
				if (interface10_0.String_2 == "http://james.newtonking.com/projects/json")
				{
					return "$" + interface10_0.String_0;
				}
				return "@" + method_2(interface10_0, xmlNamespaceManager_0);
			case XmlNodeType.Text:
				return "#text";
			case XmlNodeType.CDATA:
				return "#cdata-section";
			case XmlNodeType.ProcessingInstruction:
				return "?" + method_2(interface10_0, xmlNamespaceManager_0);
			case XmlNodeType.Comment:
				return "#comment";
			case XmlNodeType.Whitespace:
				return "#whitespace";
			case XmlNodeType.SignificantWhitespace:
				return "#significant-whitespace";
			default:
				throw new JsonSerializationException("Unexpected XmlNodeType when getting node name: " + interface10_0.XmlNodeType_0);
			case XmlNodeType.XmlDeclaration:
				return "?xml";
			}
		}

		private bool method_4(Interface10 interface10_0)
		{
			Interface10 @interface = ((interface10_0.Prop_1 != null) ? interface10_0.Prop_1.SingleOrDefault((Interface10 interface10_0) => interface10_0.String_0 == "Array" && interface10_0.String_2 == "http://james.newtonking.com/projects/json") : null);
			if (@interface != null)
			{
				return XmlConvert.ToBoolean(@interface.String_1);
			}
			return false;
		}

		private void method_5(JsonWriter jsonWriter_0, Interface10 interface10_0, XmlNamespaceManager xmlNamespaceManager_0, bool bool_2)
		{
			Dictionary<string, List<Interface10>> dictionary = new Dictionary<string, List<Interface10>>();
			for (int i = 0; i < interface10_0.Prop_0.Count; i++)
			{
				Interface10 @interface = interface10_0.Prop_0[i];
				string key = method_3(@interface, xmlNamespaceManager_0);
				if (!dictionary.TryGetValue(key, out var value))
				{
					value = new List<Interface10>();
					dictionary.Add(key, value);
				}
				value.Add(@interface);
			}
			foreach (KeyValuePair<string, List<Interface10>> item in dictionary)
			{
				List<Interface10> value2 = item.Value;
				if (value2.Count == 1 && !method_4(value2[0]))
				{
					method_6(jsonWriter_0, value2[0], xmlNamespaceManager_0, bool_2);
					continue;
				}
				string key2 = item.Key;
				if (bool_2)
				{
					jsonWriter_0.WritePropertyName(key2);
				}
				jsonWriter_0.WriteStartArray();
				for (int j = 0; j < value2.Count; j++)
				{
					method_6(jsonWriter_0, value2[j], xmlNamespaceManager_0, bool_2: false);
				}
				jsonWriter_0.WriteEndArray();
			}
		}

		private void method_6(JsonWriter jsonWriter_0, Interface10 interface10_0, XmlNamespaceManager xmlNamespaceManager_0, bool bool_2)
		{
			switch (interface10_0.XmlNodeType_0)
			{
			case XmlNodeType.Element:
				if (method_4(interface10_0) && interface10_0.Prop_0.All((Interface10 interface10_1) => interface10_1.String_0 == interface10_0.String_0) && interface10_0.Prop_0.Count > 0)
				{
					method_5(jsonWriter_0, interface10_0, xmlNamespaceManager_0, bool_2: false);
					break;
				}
				xmlNamespaceManager_0.PushScope();
				foreach (Interface10 item in interface10_0.Prop_1)
				{
					if (item.String_2 == "http://www.w3.org/2000/xmlns/")
					{
						string prefix = ((item.String_0 != "xmlns") ? item.String_0 : string.Empty);
						string uri = item.String_1;
						xmlNamespaceManager_0.AddNamespace(prefix, uri);
					}
				}
				if (bool_2)
				{
					jsonWriter_0.WritePropertyName(method_3(interface10_0, xmlNamespaceManager_0));
				}
				if (!method_17(interface10_0.Prop_1).Any() && interface10_0.Prop_0.Count == 1 && interface10_0.Prop_0[0].XmlNodeType_0 == XmlNodeType.Text)
				{
					jsonWriter_0.WriteValue(interface10_0.Prop_0[0].String_1);
				}
				else if (interface10_0.Prop_0.Count == 0 && Class192.smethod_0(interface10_0.Prop_1))
				{
					jsonWriter_0.WriteNull();
				}
				else
				{
					jsonWriter_0.WriteStartObject();
					for (int i = 0; i < interface10_0.Prop_1.Count; i++)
					{
						method_6(jsonWriter_0, interface10_0.Prop_1[i], xmlNamespaceManager_0, bool_2: true);
					}
					method_5(jsonWriter_0, interface10_0, xmlNamespaceManager_0, bool_2: true);
					jsonWriter_0.WriteEndObject();
				}
				xmlNamespaceManager_0.PopScope();
				break;
			case XmlNodeType.Comment:
				if (bool_2)
				{
					jsonWriter_0.WriteComment(interface10_0.String_1);
				}
				break;
			case XmlNodeType.Document:
			case XmlNodeType.DocumentFragment:
				method_5(jsonWriter_0, interface10_0, xmlNamespaceManager_0, bool_2);
				break;
			case XmlNodeType.Attribute:
			case XmlNodeType.Text:
			case XmlNodeType.CDATA:
			case XmlNodeType.ProcessingInstruction:
			case XmlNodeType.Whitespace:
			case XmlNodeType.SignificantWhitespace:
				if ((!(interface10_0.String_2 == "http://www.w3.org/2000/xmlns/") || !(interface10_0.String_1 == "http://james.newtonking.com/projects/json")) && (!(interface10_0.String_2 == "http://james.newtonking.com/projects/json") || !(interface10_0.String_0 == "Array")))
				{
					if (bool_2)
					{
						jsonWriter_0.WritePropertyName(method_3(interface10_0, xmlNamespaceManager_0));
					}
					jsonWriter_0.WriteValue(interface10_0.String_1);
				}
				break;
			default:
				throw new JsonSerializationException("Unexpected XmlNodeType when serializing nodes: " + interface10_0.XmlNodeType_0);
			case XmlNodeType.XmlDeclaration:
			{
				Interface13 @interface = (Interface13)interface10_0;
				jsonWriter_0.WritePropertyName(method_3(interface10_0, xmlNamespaceManager_0));
				jsonWriter_0.WriteStartObject();
				if (!string.IsNullOrEmpty(@interface.String_3))
				{
					jsonWriter_0.WritePropertyName("@version");
					jsonWriter_0.WriteValue(@interface.String_3);
				}
				if (!string.IsNullOrEmpty(@interface.String_4))
				{
					jsonWriter_0.WritePropertyName("@encoding");
					jsonWriter_0.WriteValue(@interface.String_4);
				}
				if (!string.IsNullOrEmpty(@interface.String_5))
				{
					jsonWriter_0.WritePropertyName("@standalone");
					jsonWriter_0.WriteValue(@interface.String_5);
				}
				jsonWriter_0.WriteEndObject();
				break;
			}
			}
		}

		public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
		{
			if (reader.JsonToken_0 == JsonToken.Null)
			{
				return null;
			}
			XmlNamespaceManager xmlNamespaceManager_ = new XmlNamespaceManager(new NameTable());
			Interface11 @interface = null;
			Interface10 interface2 = null;
			if (typeof(XObject).IsAssignableFrom(objectType))
			{
				if (objectType != typeof(XDocument) && objectType != typeof(XElement))
				{
					throw new JsonSerializationException("XmlNodeConverter only supports deserializing XDocument or XElement.");
				}
				XDocument document = new XDocument();
				@interface = new Class100(document);
				interface2 = @interface;
			}
			if (typeof(XmlNode).IsAssignableFrom(objectType))
			{
				if (objectType != typeof(XmlDocument))
				{
					throw new JsonSerializationException("XmlNodeConverter only supports deserializing XmlDocuments");
				}
				XmlDocument document2 = new XmlDocument();
				@interface = new Class94(document2);
				interface2 = @interface;
			}
			if (@interface != null && interface2 != null)
			{
				if (reader.JsonToken_0 != JsonToken.StartObject)
				{
					throw new JsonSerializationException("XmlNodeConverter can only convert JSON that begins with an object.");
				}
				if (!string.IsNullOrEmpty(DeserializeRootElementName))
				{
					method_8(reader, @interface, interface2, DeserializeRootElementName, xmlNamespaceManager_);
				}
				else
				{
					reader.Read();
					method_15(reader, @interface, xmlNamespaceManager_, interface2);
				}
				if (objectType == typeof(XElement))
				{
					XElement xElement = (XElement)@interface.Interface12_0.Object_0;
					xElement.Remove();
					return xElement;
				}
				return @interface.Object_0;
			}
			throw new JsonSerializationException("Unexpected type when converting XML: " + objectType);
		}

		private void method_7(JsonReader jsonReader_0, Interface11 interface11_0, XmlNamespaceManager xmlNamespaceManager_0, string string_8, Interface10 interface10_0)
		{
			switch (string_8)
			{
			case "#significant-whitespace":
				interface10_0.imethod_0(interface11_0.imethod_5(jsonReader_0.Object_0.ToString()));
				return;
			case "#whitespace":
				interface10_0.imethod_0(interface11_0.imethod_4(jsonReader_0.Object_0.ToString()));
				return;
			case "#cdata-section":
				interface10_0.imethod_0(interface11_0.imethod_3(jsonReader_0.Object_0.ToString()));
				return;
			case "#text":
				interface10_0.imethod_0(interface11_0.imethod_2(jsonReader_0.Object_0.ToString()));
				return;
			}
			if (!string.IsNullOrEmpty(string_8) && string_8[0] == '?')
			{
				method_13(jsonReader_0, interface11_0, interface10_0, string_8);
			}
			else if (jsonReader_0.JsonToken_0 == JsonToken.StartArray)
			{
				method_10(jsonReader_0, interface11_0, string_8, interface10_0, xmlNamespaceManager_0);
			}
			else
			{
				method_8(jsonReader_0, interface11_0, interface10_0, string_8, xmlNamespaceManager_0);
			}
		}

		private void method_8(JsonReader jsonReader_0, Interface11 interface11_0, Interface10 interface10_0, string string_8, XmlNamespaceManager xmlNamespaceManager_0)
		{
			if (string.IsNullOrEmpty(string_8))
			{
				throw new JsonSerializationException("XmlNodeConverter cannot convert JSON with an empty property name to XML.");
			}
			Dictionary<string, string> dictionary = method_12(jsonReader_0, xmlNamespaceManager_0);
			string string_9 = Class194.smethod_4(string_8);
			if (string_8.StartsWith("@"))
			{
				string text = string_8.Substring(1);
				string text2 = jsonReader_0.Object_0.ToString();
				string text3 = Class194.smethod_4(text);
				Interface10 interface10_ = ((!string.IsNullOrEmpty(text3)) ? interface11_0.imethod_11(text, xmlNamespaceManager_0.LookupNamespace(text3), text2) : interface11_0.imethod_10(text, text2));
				((Interface12)interface10_0).imethod_1(interface10_);
				return;
			}
			Interface12 @interface = method_14(string_8, interface11_0, string_9, xmlNamespaceManager_0);
			interface10_0.imethod_0(@interface);
			foreach (KeyValuePair<string, string> item in dictionary)
			{
				string text4 = Class194.smethod_4(item.Key);
				Interface10 interface10_2 = ((!string.IsNullOrEmpty(text4)) ? interface11_0.imethod_11(item.Key, xmlNamespaceManager_0.LookupNamespace(text4), item.Value) : interface11_0.imethod_10(item.Key, item.Value));
				@interface.imethod_1(interface10_2);
			}
			if (jsonReader_0.JsonToken_0 != JsonToken.String && jsonReader_0.JsonToken_0 != JsonToken.Integer && jsonReader_0.JsonToken_0 != JsonToken.Float && jsonReader_0.JsonToken_0 != JsonToken.Boolean && jsonReader_0.JsonToken_0 != JsonToken.Date)
			{
				if (jsonReader_0.JsonToken_0 != JsonToken.Null && jsonReader_0.JsonToken_0 != JsonToken.EndObject)
				{
					xmlNamespaceManager_0.PushScope();
					method_15(jsonReader_0, interface11_0, xmlNamespaceManager_0, @interface);
					xmlNamespaceManager_0.PopScope();
				}
			}
			else
			{
				@interface.imethod_0(interface11_0.imethod_2(method_9(jsonReader_0)));
			}
		}

		private string method_9(JsonReader jsonReader_0)
		{
			if (jsonReader_0.JsonToken_0 == JsonToken.String)
			{
				return jsonReader_0.Object_0.ToString();
			}
			if (jsonReader_0.JsonToken_0 == JsonToken.Integer)
			{
				return XmlConvert.ToString(Convert.ToInt64(jsonReader_0.Object_0, CultureInfo.InvariantCulture));
			}
			if (jsonReader_0.JsonToken_0 == JsonToken.Float)
			{
				return XmlConvert.ToString(Convert.ToDouble(jsonReader_0.Object_0, CultureInfo.InvariantCulture));
			}
			if (jsonReader_0.JsonToken_0 == JsonToken.Boolean)
			{
				return XmlConvert.ToString(Convert.ToBoolean(jsonReader_0.Object_0, CultureInfo.InvariantCulture));
			}
			if (jsonReader_0.JsonToken_0 == JsonToken.Date)
			{
				DateTime dateTime = Convert.ToDateTime(jsonReader_0.Object_0, CultureInfo.InvariantCulture);
				return XmlConvert.ToString(dateTime, Class185.smethod_1(dateTime.Kind));
			}
			if (jsonReader_0.JsonToken_0 != JsonToken.Null)
			{
				throw JsonSerializationException.smethod_1(jsonReader_0, "Cannot get an XML string value from token type '{0}'.".smethod_0(CultureInfo.InvariantCulture, jsonReader_0.JsonToken_0));
			}
			return null;
		}

		private void method_10(JsonReader jsonReader_0, Interface11 interface11_0, string string_8, Interface10 interface10_0, XmlNamespaceManager xmlNamespaceManager_0)
		{
			string string_9 = Class194.smethod_4(string_8);
			Interface12 @interface = method_14(string_8, interface11_0, string_9, xmlNamespaceManager_0);
			interface10_0.imethod_0(@interface);
			int num = 0;
			while (jsonReader_0.Read() && jsonReader_0.JsonToken_0 != JsonToken.EndArray)
			{
				method_7(jsonReader_0, interface11_0, xmlNamespaceManager_0, string_8, @interface);
				num++;
			}
			if (WriteArrayAttribute)
			{
				method_11(@interface, interface11_0);
			}
			if (num == 1 && WriteArrayAttribute)
			{
				Interface12 interface12_ = @interface.Prop_0.OfType<Interface12>().Single((Interface12 interface12_0) => interface12_0.String_0 == string_8);
				method_11(interface12_, interface11_0);
			}
		}

		private void method_11(Interface12 interface12_0, Interface11 interface11_0)
		{
			interface12_0.imethod_1(interface11_0.imethod_11("json:Array", "http://james.newtonking.com/projects/json", "true"));
			if (interface12_0 is Class101 && interface12_0.imethod_2("http://james.newtonking.com/projects/json") == null)
			{
				interface12_0.imethod_1(interface11_0.imethod_11("xmlns:json", "http://www.w3.org/2000/xmlns/", "http://james.newtonking.com/projects/json"));
			}
		}

		private Dictionary<string, string> method_12(JsonReader jsonReader_0, XmlNamespaceManager xmlNamespaceManager_0)
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			bool flag = false;
			bool flag2 = false;
			if (jsonReader_0.JsonToken_0 != JsonToken.String && jsonReader_0.JsonToken_0 != JsonToken.Null && jsonReader_0.JsonToken_0 != JsonToken.Boolean && jsonReader_0.JsonToken_0 != JsonToken.Integer && jsonReader_0.JsonToken_0 != JsonToken.Float && jsonReader_0.JsonToken_0 != JsonToken.Date && jsonReader_0.JsonToken_0 != JsonToken.StartConstructor)
			{
				while (!flag && !flag2 && jsonReader_0.Read())
				{
					switch (jsonReader_0.JsonToken_0)
					{
					case JsonToken.EndObject:
						flag2 = true;
						break;
					case JsonToken.PropertyName:
					{
						string text = jsonReader_0.Object_0.ToString();
						if (!string.IsNullOrEmpty(text))
						{
							switch (text[0])
							{
							case '@':
							{
								text = text.Substring(1);
								jsonReader_0.Read();
								string value = method_9(jsonReader_0);
								dictionary.Add(text, value);
								if (method_16(text, out var string_))
								{
									xmlNamespaceManager_0.AddNamespace(string_, value);
								}
								break;
							}
							default:
								flag = true;
								break;
							case '$':
							{
								text = text.Substring(1);
								jsonReader_0.Read();
								string value = jsonReader_0.Object_0.ToString();
								string text2 = xmlNamespaceManager_0.LookupPrefix("http://james.newtonking.com/projects/json");
								if (text2 == null)
								{
									int? num = null;
									while (xmlNamespaceManager_0.LookupNamespace("json" + num) != null)
									{
										num = num.GetValueOrDefault() + 1;
									}
									text2 = "json" + num;
									dictionary.Add("xmlns:" + text2, "http://james.newtonking.com/projects/json");
									xmlNamespaceManager_0.AddNamespace(text2, "http://james.newtonking.com/projects/json");
								}
								dictionary.Add(text2 + ":" + text, value);
								break;
							}
							}
						}
						else
						{
							flag = true;
						}
						break;
					}
					default:
						throw new JsonSerializationException("Unexpected JsonToken: " + jsonReader_0.JsonToken_0);
					}
				}
			}
			return dictionary;
		}

		private void method_13(JsonReader jsonReader_0, Interface11 interface11_0, Interface10 interface10_0, string string_8)
		{
			if (string_8 == "?xml")
			{
				string text = null;
				string text2 = null;
				string text3 = null;
				while (jsonReader_0.Read() && jsonReader_0.JsonToken_0 != JsonToken.EndObject)
				{
					switch (jsonReader_0.Object_0.ToString())
					{
					case "@standalone":
						jsonReader_0.Read();
						text3 = jsonReader_0.Object_0.ToString();
						break;
					case "@encoding":
						jsonReader_0.Read();
						text2 = jsonReader_0.Object_0.ToString();
						break;
					case "@version":
						jsonReader_0.Read();
						text = jsonReader_0.Object_0.ToString();
						break;
					default:
						throw new JsonSerializationException("Unexpected property name encountered while deserializing XmlDeclaration: " + jsonReader_0.Object_0);
					}
				}
				Interface10 interface10_ = interface11_0.imethod_6(text, text2, text3);
				interface10_0.imethod_0(interface10_);
			}
			else
			{
				Interface10 interface10_2 = interface11_0.imethod_7(string_8.Substring(1), jsonReader_0.Object_0.ToString());
				interface10_0.imethod_0(interface10_2);
			}
		}

		private Interface12 method_14(string string_8, Interface11 interface11_0, string string_9, XmlNamespaceManager xmlNamespaceManager_0)
		{
			string value = (string.IsNullOrEmpty(string_9) ? xmlNamespaceManager_0.DefaultNamespace : xmlNamespaceManager_0.LookupNamespace(string_9));
			return (!string.IsNullOrEmpty(value)) ? interface11_0.imethod_9(string_8, value) : interface11_0.imethod_8(string_8);
		}

		private void method_15(JsonReader jsonReader_0, Interface11 interface11_0, XmlNamespaceManager xmlNamespaceManager_0, Interface10 interface10_0)
		{
			while (true)
			{
				switch (jsonReader_0.JsonToken_0)
				{
				case JsonToken.Comment:
					interface10_0.imethod_0(interface11_0.imethod_1((string)jsonReader_0.Object_0));
					goto IL_0044;
				case JsonToken.PropertyName:
					if (interface10_0.XmlNodeType_0 != XmlNodeType.Document || interface11_0.Interface12_0 == null)
					{
						string string_0 = jsonReader_0.Object_0.ToString();
						jsonReader_0.Read();
						if (jsonReader_0.JsonToken_0 == JsonToken.StartArray)
						{
							int num = 0;
							while (jsonReader_0.Read() && jsonReader_0.JsonToken_0 != JsonToken.EndArray)
							{
								method_7(jsonReader_0, interface11_0, xmlNamespaceManager_0, string_0, interface10_0);
								num++;
							}
							if (num == 1 && WriteArrayAttribute)
							{
								Interface12 interface12_ = interface10_0.Prop_0.OfType<Interface12>().Single((Interface12 interface12_0) => interface12_0.String_0 == string_0);
								method_11(interface12_, interface11_0);
							}
						}
						else
						{
							method_7(jsonReader_0, interface11_0, xmlNamespaceManager_0, string_0, interface10_0);
						}
						goto IL_0044;
					}
					throw new JsonSerializationException("JSON root object has multiple properties. The root object must have a single property in order to create a valid XML document. Consider specifing a DeserializeRootElementName.");
				case JsonToken.StartConstructor:
				{
					string string_ = jsonReader_0.Object_0.ToString();
					while (jsonReader_0.Read() && jsonReader_0.JsonToken_0 != JsonToken.EndConstructor)
					{
						method_7(jsonReader_0, interface11_0, xmlNamespaceManager_0, string_, interface10_0);
					}
					goto IL_0044;
				}
				default:
					throw new JsonSerializationException("Unexpected JsonToken when deserializing node: " + jsonReader_0.JsonToken_0);
				case JsonToken.EndObject:
				case JsonToken.EndArray:
					return;
					IL_0044:
					if (jsonReader_0.JsonToken_0 != JsonToken.PropertyName && !jsonReader_0.Read())
					{
						return;
					}
					break;
				}
			}
		}

		private bool method_16(string string_8, out string string_9)
		{
			if (string_8.StartsWith("xmlns", StringComparison.Ordinal))
			{
				if (string_8.Length == 5)
				{
					string_9 = string.Empty;
					return true;
				}
				if (string_8[5] == ':')
				{
					string_9 = string_8.Substring(6, string_8.Length - 6);
					return true;
				}
			}
			string_9 = null;
			return false;
		}

		private IEnumerable<Interface10> method_17(IEnumerable<Interface10> ienumerable_0)
		{
			return ienumerable_0.Where((Interface10 interface10_0) => interface10_0.String_2 != "http://james.newtonking.com/projects/json");
		}

		public override bool CanConvert(Type valueType)
		{
			if (typeof(XObject).IsAssignableFrom(valueType))
			{
				return true;
			}
			if (typeof(XmlNode).IsAssignableFrom(valueType))
			{
				return true;
			}
			return false;
		}

		[CompilerGenerated]
		private static bool smethod_0(Interface10 interface10_0)
		{
			if (interface10_0.String_0 == "Array")
			{
				return interface10_0.String_2 == "http://james.newtonking.com/projects/json";
			}
			return false;
		}

		[CompilerGenerated]
		private static bool smethod_1(Interface10 interface10_0)
		{
			return interface10_0.String_2 != "http://james.newtonking.com/projects/json";
		}
	}
}
